VirtuDisc: Ultimate Simulator

Spring 2000

MEng Project

Christine Chung

cc95@cornell.edu

 

1 Introduction

Ultimate is the up and coming sport of the next century. Although a competitive game has never yet been broadcast over television, it has already had exposure in national and international newspapers and magazines, and it will be an exhibition sport in the upcoming World Games in Japan. Only a few high schools have Varsity Ultimate teams, and at no University is it yet considered a Varsity sport. Ultimate is played throughout the world at levels ranging from highly competitive to backyard pickup.

The VirtuDisc Simulator uses Artificial Intelligence ideas and Visual Basic code to simulate a game of competitive Women’s Ultimate. It plays a game between the club teams at Cornell and Harvard Universities, with the default player settings of Cornell’s players strong enough so that Cornell always beats Harvard, much as is the case in real life. It also features a "Change Player Attributes" option that allows the user to adjust each player’s skill level as s/he wishes.

 

2 About Ultimate

Ultimate is played with a Discraft 175 gram Ultrastar™ flying disc. The sport is a combination of football, soccer and basketball. The field dimensions are 120 yards in length (25 yard end zones inclusive) and 40 yards wide. To score, a team must complete a pass into the end zone on the opposite side of the field from which they started at the beginning of the point. Standard defenses used are person-on defense and zone defense. The standard offenses that are used against these defenses are a stack offense (players line up in the middle of the field and cut to the lanes on either side), and a zone offense. Standard positions in a stack offense include three handlers (similar to a quarterback position), two middles and two deeps. Zone will be discussed in more detail below.

2.1 Quick Rules

Here is how the rules of Ultimate are commonly abridged into a few simple concepts:  

(1) The field is a rectangular shape with end zones at each end.  

(2) Each point begins with both teams lining up on the front of their respective end zone lines. The defense throws ("pulls") the disc to the offense.  

(3) Each time the offense completes a pass into the defense's end zone, the offense scores a point.  In Ultimate, as in football, the line is considered out of bounds.  To score, your first point of contact after gaining control of the disc must be completely within the end zone lines.  Play is re-initiated after each score.  

(4) The disc may be advanced in any direction by completing a pass to a teammate. Players may not run with the disc. The person with the disc has ten seconds to throw the disc. The defender guarding the thrower ("the mark") counts out the stall count.  

(5) When a pass in not completed (e.g. out of bounds, drop, block, interception), the defense immediately takes possession of the disc and becomes the offense.  

(6) There are seven players on each team.  

2.2 Other References

To learn more about Ultimate, visit the Ultimate Players Association website at www.upa.org, or check out the Cornell Women’s team website at www.rso.cornell.edu/ultimate.

 

3 About the VirtuDisc Simulator

The VirtuDisc Simulator is a realistic, but somewhat simplified version of a competitive Ultimate game. The simulator does not account for foul calls, pick calls, time-outs, injuries, and substitutions. It simply ‘plays Ultimate’ between two teams of seven women. The user may start a new game at any time, as well as change the players’ attributes (skill levels) at any time.

3.1 Zone Offense and Defense

Only one type of offensive and defensive strategy has been implemented, namely the zone offense and defense. In zone offense, the seven standard positions are: three handlers, two wings, one popper, and one deep. These are the offensive positions that the players in VirtuDisc take on. The three handlers generally have the best throws and hence are the players who handle the disc the most. In the screenshot below (Figure 1), you can see that Harvard (in yellow) is on offense, and their three handlers are numbers 7, 8, and 9. This picture illustrates the set up of standard offensive and defensive positions in the zone. The Harvard players 11 and 12 are the wings, number 10 is the popper and 13 is the deep. On defense, the three Cornell women surrounding the thrower (#9) are referred to as the cup. The cup always runs with the disc and follows it to whomever it is thrown. Zone offensive and defensive positions are always adjusting relative to the motion of the disc. Cornell player #3 is called the rover and she guards the popper (#10), #3 and #1 are the wings (who guard the wings), and #0 is playing deep on the offensive deep #13.

 

3.2 How Realistic Is It?

VirtuDisc Simulator strives to imitate the generally intelligent, yet sometimes irrational decisions made by players in an Ultimate game. For example, when the cup has set up around the thrower, unless the thrower is a handler, her tendency will be to "dump" it to a handler who has set herself up behind the thrower for an outlet. On offense, throwers generally look for the teammates who are most open, who are furthest downfield (to maximize yardage gain), or who are handlers. They also take into account the catching skills of the receiver and the ensuing throwing skills of the receiver. If the receiver is in the scoring end zone, she will be given much greater preference, and finally an element of randomness is added to account for when throwers make seemingly irrational decisions.

In out-of-bounds situations, or after a score, when players would normally be walking back into position, the program simply resets the disc or the players to where they should be. For example, when the disc is pulled out of bounds, VirtuDisc automatically places it where it should come back into play (at the front of the end zone, closest to the y value that it went out of bounds at), and has the team on offense pick it up from there.

In another attempt to make things more realistic, a randomness factor is added whenever the disc is passed or pulled, whenever a defensive block is attempted, and whenever a decision for who to pass the disc to is made. 

3.3 The "Change Settings" Dialogue

The settings dialogue is an added feature by which the user can dynamically change the skill levels of the players on the field during a game. Each players’ attributes include: Player Name, Running Speed, Throwing Distance, Throwing Accuracy, Reaction Time, and Hands (which encompasses how well the player catches, how long her vertical/horizontal reach is, etc.) When a new game is started, these changes are still in effect. Every time VirtuDisc is completely exited, however, changes are lost and the next time the program is run, default settings take affect again.

3.3.1 How to use it

There are two ways to spawn the player settings dialogue window: (1) Go to the Game menu and click Player Attributes, or use the shortcut key Ctrl-C. (2) Click on the player whose attributes you wish to modify. This will not only load the settings form, but it will also automatically load the attributes of that player. If you used option (1), in order to load the information of the player you wish to modify, enter the jersey number of that player and click Load (or press Enter). At this point you can make changes to the player’s attribute values. If you made a mistake, click Clear Changes. If you’ve finished, click Apply Changes (this action cannot be undone). When you’re done changing the attributes of all the players you wish to modify, click DONE and the dialogue window will close.

3.3.2 What to use it for

The Change Settings dialogue is a tool that may be used to evidence the fact that the players on the field are actually acting intelligently in response to their various skill levels. Although the default settings make Cornell a much stronger team, you can increase Harvard players’ skills (and/or decrease Cornell’s players’) such that Harvard quickly becomes the dominating team.

Coaches and captains and other Ultimate players can also use this feature as a tool for getting an idea of how putting players with certain skill levels in certain positions may affect the outcome of the game.

 

4 The AI

Throughout the course of a VirtuDisc game, there are many points in time where a player is faced with a decision to make. Artificial Intelligence has been referred to as "the study of agents that exist in an environment and perceive and act" (Russel, Norvig 1995). The text also mentions that "intelligence is concerned mainly with rational action. Ideally, and intelligent agent takes the best possible action in a situation." These "intelligent agents" are what the VirtuDisc players are programmed to try to be.

The players if VirtuDisc can be considered goal-based agents, in that they are behaving in reaction to a desire to achieve their goal, which is, at any given moment, to score. In order to make their behavior more realistic however, we have added a contribution of "randomness" to account for the "chaos" factor in real life.

4.1 Formulating an Evaluation Function

Since there had never (to my knowledge) been an attempt made at simulating and automated Ultimate game, I could base the choice of my target function on nothing besides my own knowledge of the game, and a period of trial and error.

There are many factors that contribute to the decision a thrower makes when as she’s wielding the disc. She thinks about her throwing skill set, she looks for the most open receiver, she looks for the possibility of a score, and above all she tries to maintain her team’s possession of the disc. To generate a function that represented all the ideas incorporated in this list of factors, I created a list of attributes, and made an estimate of the worth of each. I then refined this formula through an extended cyclic process of observation and re-implementation, i.e. inspecting the players’ behaviors and testing different variations of the weight on each attribute to improve them.

4.2 The Formulas

Whenever someone has the disc, she has 7 options, one for each of the players on the field that she can pass the disc to, and the last is to wait. To determine the utility of each choice I used two formulas or evaluation functions.

4.2.1 When the thrower is a handler

If we assume each attribute ranges from 0 to 1, 1 being strongest, the weights that result are:

0.125*Hands + 0.125*Accuracy + (1/6)*Handler + (1/4)*YardageGain + (1/6)*Open + (1/12)*InEndzone + (1/12)*randomness

4.2.2 When the thrower is not a handler and the cup has set up

The formula is similar to that in 4.2.1, however we increase the utility of a player if she is handler. This is because when we do not have a handler with the disc and there is a cup set up around the thrower, if the thrower tries to throw through the cup, chances are the disc will turn. The formula is modified to become (roughly):

0.09*Hands + 0.9*Accuracy + (1/4)*Handler + (3/16)*YardageGain + (1/8)*Open + (1/16)*InEndzone + (1/16)*randomness

4.2.3 How the thrower finally decides

The maximum of both formulas is 1, and the thrower will choose to throw to whichever receiver comes closest to a score of 1. However, if all of the receivers’ scores (calculated using these formulas) fall below a certain specified threshold, the thrower chooses to wait.

 

5 The Forms and Methods

5.2 The Forms and Their Contents

In Visual Basic, all programming is done within a form, whether the application actually uses a form or not.  In the case of VirtuDisc, there are a total of three forms:  one for the actual game, called “Ultimate.frm”, one for the Settings Dialogue, called “settings.frm”, and one for the About box, called “AboutBox.frm.”

5.2.1 Ultimate

This form is where the action takes place.  We load the field, the disc, the players, the announcer label, and the timers all onto this form.  The playing field is actually 360x120 twips, but it spans 360x200 (900x500 pixels) including the sidelines.  The front of each end zone lies roughly 75 twips from the back.  The game timer starts enabled and is initialized to an interval of 2000 milliseconds.  The player timer has an interval of 500 ms, and the disc timer 0 (When the game starts, it is set to 100). The stall timer is how we keep track of whether the thrower has run out of her ten second limit.  Every time a new player attains possession of the disc, it is reset to 500.  

5.2.2 Settings

The settings form consists of command buttons, text fields, and labels, along with an image that is set dynamically whenever the user clicks the Load command button.  The Load button calls the fillInfo(playerNum) method, which retrieves data from the player attribute arrays and flushes them into the text fields.

5.3 The methods

There are a total of about 58 methods and functions that comprise the code for the game simulation part of VirtuDisc.  Below, some of the more central methods and functions are described.

5.3.1  gameTimer_Timer()

This method is called every time the game timer reaches 0.  It keeps game time (appropriately enough) and at 120 ticks, prompts to the user to see if s/he would like to start a new game.  It also updates the announcerTime variable, which tells the announcer label when to stop displaying the last announcement. 

5.3.2 playerTimer_Timer()

The playerTimer is essentially the main method.  It is called every time the player timer reaches 0, and its interval is 500 (1/4 that of the game timer).  When the player timer is called, the following ideas are considered:

Either the disc is not in play (a) or it is in play (b).

    (a) Either it is in between points (a1) or during a point (a2)

        (a1) Enable the discTimer and pull the disc to the other team to initiate play

        (a2) Either the disc is on the ground (a2.1), or has just been pulled and is about to hit the ground

            (a2.1) Find best person to pick up disc and move that person toward the disc.

            (a2.2) Find best person to pick up disc from where it is going to land, and move that person there.

            Move other players into position relative to disc position.

   (b) Either the disc is in the air (b1) or in someone's possession (b2)

        (b1) Find player closest to discTarget on both teams and move that player towards discTarget

        (b2) Calculate bestPass and make that pass.

 

5.3.3  discTimer_Timer()

This method is called every time the disc timer reaches 0.  It calls the discMove method each time it is called.

5.3.4 bestPass()

bestPass() loops through all players on offense who do not have the disc, and returns the player number corresponding to the player that is the best option for the thrower to pass to.  This player is determined using the formula described in section 4 above.

5.3.5 passDisc(p)

This method passes the disc to the player specified by the number p.  The discTarget values are established in this method according to where the hands of player p are.  Method discMove is then initiated.

5.3.6 canGetDisc(p)

Method canGetDisc(p) is called whenever the disc is moved, and whenever a player is moved.  When a disc is moved, canGetDisc is called with the parameter p = -1.  This specifies that the function should check through all players on the field and see if any of them can reach the disc.  If a player is on offense and can reach the disc, she catches it.  If a player is on defense and can reach the disc, depending on her reaction time and hands attribute, she will make the defensive block or not make the block.  When a player is moved, the method is called with the parameter p = playerNum, and the method checks if that player only can reach the disc.  If so, she catches it or D's it accordingly. 

5.3.7  movePlayerToSpot(p,x,y,goFor)

This method is called whenever we have decided where we want a player to go.  The goFor is a boolean parameter that indicates whether or not we should also have the player "go for" the disc (see if it is within reach and if so, catch or D).  x and y specify the position the player should move to, and p is the player we are moving.

5.3.8 pull()

This method finds a spot in the end zone, based mostly on randomness, partly on the accuracy of the thrower, and partly on an ideal location for a pull, and sets the discTarget to be this spot.   discMove is then called.

5.3.9 setDiscPos(x,y)

Sets the disc position to (x,y), unless x and y are -1, in which case the disc position is set to what is in the contents of the discPos array (which holds an x coordinate and a y coordinate), in which case the contents of discPos should have been previously determined.  If the new disc position is out of bounds, it sets it to the spot that it went out of bounds at.  It also moves the actual disc on the Ultimate form to the new position.

5.3.10 discMove(pull)

discMove() is called by the passDisc(), discTimer_Timer() and pull() methods.  When it is called by pull(), the input parameter pull = True so that the method will not then allow the rest of the players to go for the disc.  The only player who will go for the disc will be the player that was chosen 'toPickUp' the disc in the playerTimer method.  discMove() simply moves the disc a certain distance (depending on the throwing power of the player, which is indicated by the throwing distance attribute)  in the direction that it was thrown in.

5.3.11 init()

This method initializes the Ultimate form and all the variables for the program.  It calls functions to load all player data (from the players.txt file), load the players images, load the disc, and load the players' starting positions.

5.3.13 moveIntoPos(p,dX,dY)

This function is called by the playerTimer_Timer method and tells the players to move into appropriate offensive and defensive positions based on the current position of the disc, or the impending position of the disc (if the disc is in the air) (dX, dY), and the player who is currently holding the disc (p).  

 

6 Future Improvements

One of the biggest lessons I've taken from building this program is that there are an infinite number of improvements to make.  I could conceivably extend this project out to years and years of work.  Not only can I drastically improve the animation and graphics, or implement more of the strategies used in an Ultimate game, but I can also try to implement a learning algorithm so that each player learns, or I can improve the players' behavior so that some decisions that are currently not intelligently made become dependent on many factors as the bestPass decision does.  Some of these improvements are discussed in more detail below.

6.1 More Choices

Oftentimes, the players are actually not acting intelligently and deciding what actions to take based on their environment.  Sometimes they just blindly run to the position they are supposed to be in given a certain disc position.  I could formulate more decision functions based on more factors than disc position that would help these players determine where the best place is to run to.  I could also implement a somewhat random behavior (that would simulate ultimate more realistically) where the handler would sometimes choose to throw to an open space, and hope that a player runs the disc down, while other times throwing to a receiver.

6.2  Learning

To make them even smarter, the players should grow knowledge about all other players and change their behaviors as a result.  For example, if someone has been D blocked five times by a someone else, she shouldn't try to throw the disc near that person anymore.   In that same vein, I could train the players to learn based on a target function.  This would allow them to slowly make better and better choices, and this would allow user to project the potential of their current players in a game situation.  To simulate the learning process would be very useful as a tool as well as interesting as more convincing as a simulation.  

6.3 As a Tool

If a learning algorithm were to be implemented, it would also increase this application’s usefulness as a tool.  For example, let the learning algorithm take into account the players on the team, their skills, and their positions, and whether or not the team won or lost.  If each team is always allotted only a fixed number of “power points” to distribute across the entire team’s skill settings, we could use the learning algorithm to eventually determine what a maximal distribution of these “power points” is, and hence get an indication of where certain skills are most valuable.  In the end, each of these “power points” can represent an hour spent coaching a player in a certain skill.  The program can be used to determine how to most effectively distribute the time a coach spends.

 

7 Thanks

Thanks to Professor Selman and Dan Ryazansky for allowing me to study and learn from Ryazansky’s Shepherd Soccer program, also written in Visual Basic.  (Incidentally, the players in VirtuDisc are slightly modified Shepherd Soccer players – luckily Ultimate players and soccer players have similar uniforms.)  Thanks also to Félix Rodríguez for his help with Visual Basic.